package com.senior.lock;

import java.util.concurrent.TimeUnit;

public class Lock8Demo {

    public static void main(String  [] args) throws InterruptedException {
        Phone phone = new Phone();
        Phone phone2 = new Phone();
        new Thread(() -> {
            phone.Hello();
        }, "A").start();

        new Thread(() -> {
            phone2.sendSms();
        }, "B").start();


    }
}

class Phone{
    public  synchronized void sendSms(){
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("----Sms----");
    }

    public  synchronized void sendEmail(){

        System.out.println("----Email----");
    }

    public  void Hello(){
        System.out.println("----Hello----");
    }
}
